package cn.tedu.ymg.product.controller;

import cn.tedu.ymg.commons.pojo.vo.PageData;
import cn.tedu.ymg.commons.web.JsonResult;
import cn.tedu.ymg.product.pojo.vo.CaseListItemVO;
import cn.tedu.ymg.product.service.ICaseService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/case2")
@Api(tags = "12.方案类型图片模块")
@Slf4j
@Validated
public class CaseUrlController {

    @Autowired
    ICaseService service;

    @GetMapping("{id}")
    @ApiOperation("根据ID查询方案类型图片")
    @ApiOperationSupport(order = 410)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "方案ID", name = "id", required = true, dataType = "long"),
    })
    public JsonResult getUrlById(@Range(min = 1, message = "根据ID查询方案失败,请提交合法的ID值")
                                 @PathVariable Long id) {
        log.debug("开始处理【根据ID查询方案类型图片】的请求，参数：{}", id);
        PageData<CaseListItemVO> pageData = service.getUrlById(id);
        return JsonResult.ok(pageData);
    }
}